CC=g++
MAKE=make
SRC=src
BIN=bin
INCLUDES=-Iincludes -Imesoscopic2
OPTIONS=-g -fPIC -pthread -DDEBUG
PYTHON_HEADER=/usr/include/python2.7 

OBJECTS= log.o \
	utils.o \
	options/Options.o \
	controller/TLSController.o \
	controller/TimeIncrementCalculationStrategy.o \
	controller/Case.o controller/CaseGroup.o controller/CaseRecycler.o \
	localview/Node.o localview/LocalView.o localview/Street.o \
	localview/Link.o localview/Phase.o \
    evolutive/TimeIncrementEvolutiveStrategy.o \
    evolutive/Context.o evolutive/Dna.o \
	evolutive/EventListener.o \
	evolutive/CaseGenerator.o evolutive/CaseSelector.o \
	evolutive/EvolutiveCaseGenerator.o evolutive/CaseGeneratorFactory.o \
	evolutive/FitnessFunction.o evolutive/LifeSimulator.o \
	evolutive/OffspringGenerator.o \
	evolutive/impl/NakamitFitnessFunction.o evolutive/impl/RouletteWheelSelector.o \
	evolutive/impl/StubLifeSimulator.o evolutive/RandomCaseGen.o \
	evolutive/impl/MesoscopicTrafficSimulation.o \
	evolutive/EvolutiveCaseGeneratorBuilder.o \
	mesoscopic2/XMLOutputMesoscopicInterface.o \
	mesoscopic2/Controller.o mesoscopic2/Network.o mesoscopic2/SimulationNode.o \
	mesoscopic2/NodeInput.o mesoscopic2/CarBundle.o mesoscopic2/TLSPhase.o \
	mesoscopic2/TLSLink.o mesoscopic2/NodeSource.o

all: $(OBJECTS) python_interface

%.o: %.cpp 
	$(CC) $(OPTIONS) $(INCLUDES) -c -o $@ $<

static_lib:
	ar rcs librsi.a $(OBJECTS)

python_interface: rsi.i
	swig -c++ -python -outdir traci_interface rsi.i
	g++ -c -fPIC rsi_wrap.cxx -o traci_interface/rsi_wrap.o $(INCLUDES) -I$(PYTHON_HEADER)
	g++ -shared $(OPTIONS) $(OBJECTS) $(LIBS) traci_interface/rsi_wrap.o -o traci_interface/_rsi.so

tests: $(OBJECTS) static_lib
	cd test && $(MAKE) clean
	cd test && $(MAKE) test

clean:
	rm -f $(OBJECTS) traci_interface/_rsi.so traci_interface/rsi.py rsi_wrap.cxx traci_interface/rsi_wrap.o librsi.a
	cd test && $(MAKE) clean
